﻿using System;
using System.Windows;
using ScreenReaderAPIWrapper;

namespace ScreenReaderAPIWrapperTester
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private ScreenReader screenReader;
        
        public MainWindow()
        {
            InitializeComponent();
            screenReader = new ScreenReader();
            screenReader.SapiEnabled = true;
        }

        private void speakButton_Click(object sender, RoutedEventArgs e)
        {
            if (speakBox.Text != String.Empty)
            {
                if (useSapiBox.IsChecked == true)
                {
                    screenReader.SAPISayString(speakBox.Text);
                }
                else
                {
                    screenReader.SayString(speakBox.Text);
                }
            }
        }

        private void pauseButton_Click(object sender, RoutedEventArgs e)
        {
            screenReader.StopSpeech();
        }

        private void readerIdentifyButton_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("Screen reader " + screenReader.ScreenReaderName + " detected.", "Returned", MessageBoxButton.OK, MessageBoxImage.Information);
        }

        private void increaseSAPIRateButton_Click(object sender, RoutedEventArgs e)
        {
            screenReader.SapiRate += 5;
            ReadSAPIRate();
        }

        private void decreaseSAPIRateButton_Click(object sender, RoutedEventArgs e)
        {
            screenReader.SapiRate -= 5;
            ReadSAPIRate();
        }

        private void ReadSAPIRate()
        {
            screenReader.SAPISayString("SAPI rate set to " + screenReader.SapiRate.ToString());
        }


    }
}